﻿using Castle.MicroKernel.Registration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace MRSite.Common.Dependency
{
    public class BasicRegister : IBasicRegister
    {
        public void RegistAssembly(Assembly assembly, IContainerManager containerManager)
        {
            containerManager.Container.Register(
                Classes.FromAssembly(assembly)
                .IncludeNonPublicTypes()
                .BasedOn<ITransient>()
                .WithService.Self()
                .WithService.DefaultInterfaces()
                .LifestyleTransient()
                );

            containerManager.Container.Register(
                Classes.FromAssembly(assembly)
                .IncludeNonPublicTypes()
                .BasedOn<ISingleton>()
                .WithService.Self()
                .WithService.DefaultInterfaces()
                .LifestyleSingleton()
                );
        }
    }
}
